package at.fhooe.swa.client.ui;

import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.jfree.util.UnitType;

public class TextPanel extends JPanel
{
	String val = null;
	String unit = null;
	JLabel label = null;
	
	public TextPanel(String title, String unit, String initVal)
	{
		this.val = initVal;
		this.unit = unit;
		
		this.add(getLabel());
		setLabel();
		this.setBorder(BorderFactory.createTitledBorder(title));
	}
	
	private void setLabel()
	{
		getLabel().setText(this.unit + this.val);
	}
	
	private JLabel getLabel()
	{
		if (label == null)
		{
			label = new JLabel();
			label.setFont(new Font("Dialog", Font.BOLD, 14));
		}
		return label;
	}
	
	public void updateValue(String value)
	{
		this.val = value;
		setLabel();
	}
}
